<title>设置系统配置</title>
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>设置系统配置</cite></a>
    </div>
</div>
<style>
    .layui-upload-img {
        width: 100px;
        height: auto;
    }
</style>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">设置系统配置</div>

                <!--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend>页面设置</legend>
                </fieldset>-->

                <div class="layui-card-body">
                    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list"
                        style="padding: 0px 30px 0 0;">

                        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                            <legend>商城配置</legend>
                        </fieldset>

                        <!--<div class="layui-form-item">
                            <label class="layui-form-label">体验会员 <span style="color:red">*</span></label>
                            <div class="layui-input-inline">
                                <select name="isOpenExperienceMember">
                                    <option value="1">开启</option>
                                    <option value="0">关闭</option>
                                </select>
                            </div>
                            <span style="color:#c2c2c2">开启时新注册用户会员等级自动变为体验会员</span>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">体验会员有效期 <span style="color:red">*</span></label>
                            <div class="layui-input-inline">
                                <input type="text" name="experienceMemberValidity" autocomplete="off"
                                    lay-verify="number" class="layui-input">
                            </div>
                            <span style="color:#c2c2c2">单位：天</span>
                        </div>-->
                        <div class="layui-form-item">
                            <label class="layui-form-label">默认运费 <span style="color:red">*</span></label>
                            <div class="layui-input-inline">
                                <input type="text" name="defaultFarePrice" autocomplete="off" lay-verify="number"
                                    class="layui-input">
                            </div>
                            <span style="color:#c2c2c2">默认最低运费 包邮时不计算</span>
                        </div>


                        <div class="layui-form-item">
                            <label class="layui-form-label">发货单撤回时间 <span style="color:red">*</span></label>
                            <div class="layui-input-inline">
                                <input type="text" name="SendDataTime" autocomplete="off" 
                                    class="layui-input">
                            </div>
                            <span style="color:#c2c2c2">单位：小时 </span>
                        </div>



                        <!--<div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">店铺名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="ShopName" autocomplete="off" lay-verify="required" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">店铺Logo</label>
                                <div class="layui-input-block">
                                    <div class="layui-upload">
                                        <button type="button" class="layui-btn layui-btn-sm" id="selectImg">选择图片</button>
                                        <div class="layui-upload-list" id="divImgs"></div>
                                        <input type="hidden" name="Logo" id="Logo">
                                        <hr />
                                    </div>
                                </div>
                            </div>
                        </div>-->


                        <!--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                            <legend>微信参数配置</legend>
                        </fieldset>

                        <div class="layui-form-item">
                            <label class="layui-form-label">小程序AppID <span style="color:red">*</span></label>
                            <div class="layui-input-inline" style="width:380px">
                                <input type="text" name="wxAppID" autocomplete="off" lay-verify="required"
                                    class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">小程序AppSecret<span style="color:red">*</span></label>
                            <div class="layui-input-inline" style="width:380px">
                                <input type="text" name="wxAppSecret" autocomplete="off" lay-verify="required"
                                    class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">公众号AppID</label>
                            <div class="layui-input-inline" style="width:380px">
                                <input type="text" name="gzhAppID" autocomplete="off" lay-verify="" class="layui-input">
                            </div>
                            <span style="color:#c2c2c2">发送小程序服务消息</span>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">商户号<span style="color:red">*</span></label>
                            <div class="layui-input-inline" style="width:380px">
                                <input type="text" name="wxMchid" autocomplete="off" lay-verify="required"
                                    class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">密钥<span style="color:red">*</span></label>
                            <div class="layui-input-inline" style="width:380px">
                                <input type="text" name="wxKey" autocomplete="off" lay-verify="required"
                                    class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">商户号证书路径<span style="color:red">*</span></label>
                            <div class="layui-input-inline" style="width:380px">
                                <input type="text" name="certPath" autocomplete="off" lay-verify="required"
                                    class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">商户号证书密钥<span style="color:red">*</span></label>
                            <div class="layui-input-inline" style="width:380px">
                                <input type="text" name="certPassword" autocomplete="off" lay-verify="required"
                                    class="layui-input">
                            </div>
                        </div>-->

                        <!--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                            <legend>其他设置</legend>
                        </fieldset>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">默认运费</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="Freight" autocomplete="off" lay-verify="number"  class="layui-input">
                                </div>
                            </div>
                        </div>-->

                        <div class="layui-form-item">
                            <div class="layui-input-inline">
                                <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" value="提交"
                                    class="layui-btn">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<script>
    layui.use(['form', 'admin', 'upload', 'formSelects'], function () {
        var form = layui.form;//required（必填项）phone（手机号）email（邮箱）url（网址）number（数字）date（日期）identity（身份证） 自定义值
        var $ = layui.$;
        admin = layui.admin;
        upload = layui.upload;
        var formSelects = layui.formSelects;

        form.on('submit(layuiadmin-app-form-submit)', function (data) {
            //添加进去
            admin.req({
                url: layui.setter.APIUrl + '/admin/configMgr/updateorAddSysConfig' //实际使用请改成服务端真实接口
                , data: { "configstr": JSON.stringify(data.field), "groupId": layui.router().search.GroupId }
                , type: "post"
                , done: function (res) {
                    layer.msg('成功');
                    //window.location.href = '#/admin/Portal_Group/'
                    // layer.msg(JSON.stringify(data.field));
                    // return false;
                }
            });
        });

        //首先获取到组织的id
        admin.req({
            url: layui.setter.APIUrl + '/admin/configMgr/getGroupSysConfig' //实际使用请改成服务端真实接口
            , data: { "groupId": layui.router().search.GroupId }
            , type: "post"
            , done: function (res) {
                //设置值
                form.val("layuiadmin-app-form-list", res.Data.model);

                var pics = res.Data.model.Logo;
                if (pics != "" && pics != null && pics != 'null') {
                    addImg(pics);
                }
            }
        });

        var uploadInst = upload.render({
            elem: '#selectImg'
            , url: '/WebAPI/file/uploadImg?access_token=' + layui.data('layuiAdmin').access_token
            , acceptMime: 'image/*'
            , multiple: false
            , done: function (res) {
                if (res.ResultCode == 0) {
                    addImg(res.Data.src);
                    layer.msg('上传成功');
                } else {
                    layer.msg(res.ResultInfo);
                }
            }
        });

        form.render();
    });


    function addImg(src) {
        var $ = layui.$;

        var div = "divimg3";
        var img = "Img3";
        var html = "    <div style=\"line-height:100px;float:left\" id='" + div + "'> " +
            " <img id='" + img + "' src=\"" + src + "\"   alt=\"\" class=\"layui-upload-img\">" +
            "</div>";
        $('#divImgs').html(html);
        $("#Logo").val(src);
    }


</script>